package org.helloroad;

import java.io.Serializable;

import org.ksoap2.serialization.SoapObject;

public class Trip implements Serializable
{
	/** Serial UID */
	private static final long serialVersionUID = 1937530129810029744L;

	private Integer id;
	private String from;
	private String to;
	private String date;
	private String time;
	public Integer driver_id;
	public boolean monday;
	public boolean tuesday;
	public boolean wednesday;
	public boolean thursday;
	public boolean friday;
	public boolean saturday;
	public boolean sunday;
	
	/**
	 * Allows to build a Trip from a SoapObject
	 * @param o
	 */
	public Trip(SoapObject o)
	{
		this.id 				= Integer.parseInt(o.getProperty("id").toString());
		this.from 			= o.getProperty("from").toString();
		this.to 				= o.getProperty("to").toString();
		if (o.getProperty("driver_id") != null)
			this.driver_id = Integer.parseInt(o.getProperty("driver_id")
					.toString());
		this.time = o.getProperty("time").toString();
		if (o.getProperty("date") != null
				&& o.getProperty("date").toString().equals("") == false)
		{
			this.date = o.getProperty("date").toString();
		}
		else
		{
			if (Integer.parseInt(o.getProperty("monday").toString()) == 1)
				this.monday = true;
			if (Integer.parseInt(o.getProperty("tuesday").toString()) == 1)
				this.tuesday = true;
			if (Integer.parseInt(o.getProperty("wednesday").toString()) == 1)
				this.wednesday = true;
			if (Integer.parseInt(o.getProperty("thursday").toString()) == 1)
				this.thursday = true;
			if (Integer.parseInt(o.getProperty("friday").toString()) == 1)
				this.friday = true;
			if (Integer.parseInt(o.getProperty("saturday").toString()) == 1)
				this.saturday = true;
			if (Integer.parseInt(o.getProperty("sunday").toString()) == 1)
				this.sunday = true;
		}
	}
	
	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}
	public String getFrom()
	{
		return from;
	}
	public void setFrom(String from)
	{
		this.from = from;
	}
	public String getTo()
	{
		return to;
	}
	public void setTo(String to)
	{
		this.to = to;
	}
	
	public String getDate() {
		return date;
	}

	public void setDate(String date)
	{
		this.date = date;
	}

	/**
	 * @param time
	 *            the time to set
	 */
	public void setTime(String time) {
		this.time = time;
	}

	/**
	 * @return the time
	 */
	public String getTime() {
		return time;
	}

	@Override
	public String toString() {
		return from + " - " + to + " - " + time;
	}
}
